package com.atguigu.springboot02advanced.controller;

import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.filter.HiddenHttpMethodFilter;

@RestController
public class HttpRestController {

    @GetMapping(value = "/user")
    public String getUser(){
        return "GET-张三";
    }

    @PostMapping(value = "/user")
    public String saveUser(){
        return "POST-张三";
    }


    @PutMapping(value = "/user")
    public String putUser(){
        return "PUT-张三";
    }

    @DeleteMapping(value = "/user")
    public String deleteUser(){
        return "DELETE-张三";
    }

    //自定义filter
    @Bean
    public HiddenHttpMethodFilter hiddenHttpMethodFilter(){
        HiddenHttpMethodFilter methodFilter = new HiddenHttpMethodFilter();
        methodFilter.setMethodParam("_m");
        return methodFilter;
    }
}
